/**
* Created by Administrator on 2025/5/7.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "AICFARNet/AICFARNet.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "MyDeviceWriter/MyDeviceWriter.h"
#include "MyDeviceReader_1/MyDeviceReader_1.h"
#include "AICFARTrainController/AICFARTrainController.h"
#include "EthernetReader.h"
#include "EthernetWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=7;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(AICFARNet,MyDeviceReader,MyDeviceReader_1,MyDeviceWriter,AICFARTrainController);
    auto aiCFARNet = new AICFARNet();
    auto aiCFARTrainController = new AICFARTrainController();

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(aiCFARNet,0,1024);
    radarlabReader->addTaskModule(aiCFARTrainController,0,1024);

    auto radarlabReader_1 = new MyDeviceReader_1();
    radarlabReader_1->addTaskModule(aiCFARNet,1,1024);

    auto radarlabReader_2 = new EthernetReader(TCP,6673);
    radarlabReader_2->addTaskModule(aiCFARTrainController,1,1024);

    auto radarlabReader_3 = new EthernetReader(TCP,6679);
    radarlabReader_3->addTaskModule(aiCFARTrainController,2,1024);

    aiCFARTrainController->setLaunchPolicy(LaunchMode_OR,LaunchCondition());

    auto radarlabWriter = new MyDeviceWriter();
    aiCFARNet->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_1 = new MyDeviceWriter();
    aiCFARTrainController->addDeviceWriter(0,radarlabWriter_1,1024);

    auto radarlabWriter_2 = new EthernetWriter(TCP,"192.168.1.115",6676,true);
    aiCFARNet->addDeviceWriter(1,radarlabWriter_2,1024);
    REGISTER_INSTANCES(aiCFARNet,radarlabReader,radarlabReader_1,radarlabWriter,radarlabWriter_2,aiCFARTrainController,radarlabReader_2,radarlabReader_3,radarlabWriter_1);
}
